<?php
class ResponseHTM
{
	public $header = null;
	
	private $string = '';
	private $data = null;
	
	/**
	 * HTM response
	 *
	 * @param string $name object name
	 * @param array $output output settings for XSLT
	 */
	public function __construct($name, $outputs = array(), $data = null)
	{
		if (is_null($data)) {
			$data = new ResponseXML($name);
		}
		
		$this->data = (string)$data;
		
		$xsl_dom = new ResponseXSL($name, $outputs);
		
		$xml_dom = new DOMDocument();
		//$xml_dom->recover = true;
		//$xml_dom->substituteEntities = true;
		$xml_dom->loadXML($this->data);
		
		$xslt = new XSLTProcessor();
		$xslt->importStyleSheet($xsl_dom);
		
		$this->string = $xslt->transformToXML($xml_dom);
	}
	
	/**
	 * Data getter.
	 *
	 * @return ResponseXML
	 */
	public function getData()
	{
		return $this->data;
	}
	
	public function __toString()
	{
		return rtrim($this->string);
	}
}
?>